package s21.ch24.ex1;

public class MyWaitNotify {

	private static Object monitor = new Object();
	
	public static class MyThread extends Thread {

		@Override
		public void run() {
			System.out.println("Jestem thread");
			try {
				synchronized (monitor) {
					monitor.wait();					
				}
			} catch (InterruptedException e) {
				System.out.println("Przerwany");
			}
			System.out.println("Koniec watku");
		}
	}

	public static void main(String[] args) throws Exception {

		MyThread t1 = new MyThread();
		t1.start();
		MyThread t2 = new MyThread();
		t2.start();
		synchronized (monitor) {
			monitor.notifyAll();			
		}
	}

}
